package com.link.linkupjavaweb.utils;

import com.link.linkupjavaweb.common.Constants;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * 账号生成工具类
 */
public class AccountGenerator {
    
    // 账号序号，从10开始（因为测试数据已经有001-005和999）
    private static final AtomicInteger accountSequence = new AtomicInteger(10);
    
    /**
     * 生成唯一账号
     * 格式：XXX@Link.com
     * @return 账号
     */
    public static String generateAccount() {
        int sequence = accountSequence.incrementAndGet();
        // 格式化为3位数，不足补0
        String sequenceStr = String.format("%03d", sequence);
        return sequenceStr + Constants.ACCOUNT_SUFFIX;
    }
    
    /**
     * 设置起始序号（用于系统初始化）
     * @param startSequence 起始序号
     */
    public static void setStartSequence(int startSequence) {
        accountSequence.set(startSequence);
    }
}

